package com.lemon.smartsafetynew.util.common;

import android.graphics.Color;

import com.github.mikephil.charting.charts.BarChart;
import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.components.Legend;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.components.YAxis;

/**
 * Created by Andrew on 2017/8/20.
 */


public class MPChartUtils {

    public static void lineChartCommonSettings(LineChart lineChart) {

        lineChart.setNoDataText("无数据");
        lineChart.setPinchZoom(false);
        lineChart.setScaleYEnabled(false);
        lineChart.setScaleXEnabled(false);
        lineChart.setDrawGridBackground(false);
        lineChart.setDrawBorders(false);
        lineChart.getDescription().setEnabled(false);
        lineChart.setDoubleTapToZoomEnabled(false);


        XAxis xAxis = lineChart.getXAxis();
        xAxis.setDrawGridLines(false);
        xAxis.setTextColor(Color.WHITE);
        xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
        xAxis.setAvoidFirstLastClipping(true);
        //xAxis.setAxisLineColor(Color.parseColor(AppConstants.COLOR_XAXIS));
        xAxis.setAxisLineWidth(1f);


        YAxis leftAxis = lineChart.getAxisLeft();

        leftAxis.setDrawGridLines(false);
        leftAxis.setEnabled(false);
        leftAxis.setSpaceTop(15f);

        YAxis rightAxis = lineChart.getAxisRight();

        rightAxis.setDrawGridLines(false);
        rightAxis.setEnabled(false);
        rightAxis.setSpaceTop(15f);

        Legend legend = lineChart.getLegend();
        legend.setEnabled(false);
    }

    public static void barChartCommonSettings(BarChart barChart) {
        barChart.setNoDataText("无数据");
        barChart.setDrawGridBackground(false);
        barChart.setDrawBorders(false);
        barChart.getDescription().setEnabled(false);

        barChart.setDoubleTapToZoomEnabled(false);
        barChart.setPinchZoom(false);
        barChart.setScaleYEnabled(false);
        barChart.setScaleXEnabled(true);
        barChart.setDrawBarShadow(false);
        barChart.setDrawValueAboveBar(true);


        XAxis xAxis = barChart.getXAxis();
        xAxis.setDrawGridLines(false);
        xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
        //xAxis.setSpaceBetweenLabels(4);
        xAxis.setTextColor(Color.WHITE);
        //xAxis.setAxisLineColor(Color.parseColor(AppConstants.COLOR_XAXIS));
        xAxis.setAxisLineWidth(1f);

        //xAxis.setAxisLineWidth(3f);


        YAxis leftAxis = barChart.getAxisLeft();

        leftAxis.setDrawGridLines(false);
        leftAxis.setSpaceTop(15f);
        leftAxis.setAxisMinValue(0f);
        //leftAxis.setDrawLabels(false);
        leftAxis.setEnabled(false);

        YAxis rightAxis = barChart.getAxisRight();

        rightAxis.setDrawGridLines(false);
        rightAxis.setAxisMinValue(0f);
        rightAxis.setSpaceTop(15f);
        //rightAxis.setDrawLabels(false);
        rightAxis.setEnabled(false);

        Legend legend = barChart.getLegend();
        legend.setEnabled(false);


    }

}
